Skip to content

Builder Extensions: Make AddWebComponents() idempotent (closes #22344)#22347

Merged
kjac merged 1 commit intomainfrom
v17/bugfix/make-add-web-components-idempotent
Apr 7, 2026
Merged

Builder Extensions: Make AddWebComponents() idempotent (closes #22344)#22347
kjac merged 1 commit intomainfrom
v17/bugfix/make-add-web-components-idempotent

Conversation

@AndyButland
Copy link
Copy Markdown
Contributor

@AndyButland AndyButland commented Apr 3, 2026

Description

#22344 raises a concern that from 17.3, after we'd introduced support for running Umbraco with different components of backoffice, website and Delivery API in #21630, that the AddWebComponents() wasn't made idempotent.

This PR adds an idempotency guard to AddWebComponents() using the same marker-class pattern already used by AddCore(), preventing duplicate health check registration when AddWebComponents() is called explicitly after AddBackOffice().

Testing

Automated

A regression integration test has been added that reproduces the exact scenario from the issue and asserts HealthCheckService can be resolved without duplicate name errors.

Manual

See steps to reproduce on the linked issue. Before the fix an exception would be thrown. Now the application will start normally.

Copilot AI review requested due to automatic review settings April 3, 2026 14:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes IUmbracoBuilder.AddWebComponents() safe to call multiple times by adding an idempotency guard consistent with the existing AddCore() pattern, preventing duplicate DI registrations (notably duplicate health checks) when AddWebComponents() is invoked explicitly after higher-level builder calls.

Changes:

  • Added a marker-based idempotency guard to AddWebComponents() to ensure it runs only once per service collection.
  • Added an integration regression test covering the exact call chain that previously caused duplicate "umbraco-ready" health check registration failures.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs Adds a marker singleton + early-return guard to make AddWebComponents() idempotent and avoid duplicate registrations.
tests/Umbraco.Tests.Integration/TestServerTest/CoreConfigurationTests.cs Adds AddWebComponents_IsIdempotent regression test to ensure HealthCheckService resolves without duplicate-name exceptions after the problematic builder chain.

@AndyButland AndyButland changed the title Builder Extensions: Make AddWebComponents() idempotent (closes #22344) Builder Extensions: Make AddWebComponents() idempotent (closes #22344) Apr 3, 2026
Copy link
Copy Markdown
Contributor

@kjac kjac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@kjac kjac merged commit cd541b6 into main Apr 7, 2026
32 checks passed
@kjac kjac deleted the v17/bugfix/make-add-web-components-idempotent branch April 7, 2026 05:07
AndyButland added a commit that referenced this pull request Apr 7, 2026
…) (#22347)

Ensure AddWebComponents is idempotent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants